|
|
|
|
|
|
|
Behavior is in the eyes of the beholder. That is, it is meaningful to the client of the object. For example, you, as a medical client of your doctor, know that she can perform surgery on a bad knee. You don't know exactly how she does what she does, but you know she can repair your knee and heal any associated pain in the process. Therefore, you care only about the surgery behavior she exhibits when your knee is hurt. |
|
|
|
|
|
|
|
|
Attributes are, in part, what make a class of objects unique from another class of objects. They are variables, in a sense, that hold an object's current state. For example, given a BankCustomer class with a Name attribute, this class's state of object could be represented by a name value of John Doe. The state of an object is the value of its attributes at a given point in time. In Visual Basic, attributes are represented as properties. |
|
|
|
|
|
|
|
|
New Term: State is the value of an object's attributes at a given point in time. |
|
|
|
|
|
|
|
|
The structure of a class is physically deployed differently in different programming languages, though the structure itself remains the same. For instance, in C++, the class is usually separated into a header filefor definitions of the class itself as well as its methods and properties (attributes)and an implementation file that shows how each member (method or property) of the class is used in a particular domain. In Visual Basic, there is no such distinctionat least, not quite (more on this in a moment). |
|
|
|
|
|
|
|
|
The Visual Basic class module is virtually the same as the familiar form module, a fact that has, unfortunately, led to some confusion over the difference between the graphical user interface form object and the class module. For example, both a form module and a class module can implement (inherit) the interface (public methods and properties) of another class. You can add properties and methods to both types of modules. Both have a constructor and destructor (Form_Load, Form_Unload, Class_Initialize, Class_Terminate). As a result, many Visual Basic developers place lots of business logic code into forms that make it difficult to try to reuse such code, much less partition the application into packages that can then be assigned to individual developers on a team. Figure 1.1 shows what a typical class module looks like. |
|
|
|
|
|
|
|
|
A class module consists of both the definition and implementation of class members. These class members are methods (functions or subs) and properties (variables that hold information about an object whose type is defined by a class). The members of a class can be defined as either public, private, or friend. |
|
|
|
|
|